﻿<UserControl x:Class="ListOfLists_WPF.InnerListControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignWidth="200" d:Margin="3,3,3,3">
    <!-- d:DesignHeight="350" -->
    <DockPanel LastChildFill="true">
        <DockPanel LastChildFill="true" DockPanel.Dock="Top">
            <Button x:Name="buttonAdd" DockPanel.Dock="Right" Background="Green" Click="OnNewItem">+Add</Button>
            <TextBox x:Name="titleText" DockPanel.Dock="Left" Background="Yellow" Text="Title" TextAlignment="Left" IsReadOnly="True"/>
        </DockPanel>
        <ScrollViewer x:Name="scroller" DockPanel.Dock="Bottom" VerticalScrollBarVisibility="Auto">
            <ListBox x:Name="innerList" PreviewMouseLeftButtonDown="OnPreviewMouseLeftButtonDown" PreviewMouseRightButtonDown="OnPreviewMouseRightButtonDown" HorizontalAlignment="Left" 
                 AllowDrop="True" Drop="OnDrop" VerticalAlignment="Stretch"  Width="200" Height="{Binding ElementName=LayoutRoot, Path=ActualHeight}" MinHeight="100">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Border BorderThickness="2" BorderBrush="Black" Background="{Binding Path=Color}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>

                                <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0">
                                    <TextBlock Text="{Binding Path=Description}" FontSize="24" Foreground="DarkGreen" TextAlignment="Center" Margin="2,2,2,2">
                                        <TextBlock.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Header="Delete" Tag="{Binding}" Click="OnDeleteItem"/>
                                                <!--
                                                <Separator/>
                                                <MenuItem Header="White" Tag="{Binding}" Foreground="White" Background="White" Click="OnSetColor"/>
                                                <MenuItem Header="Red" Tag="{Binding}" Foreground="Red" Background="Red" Click="OnSetColor"/>
                                                <MenuItem Header="Yellow" Tag="{Binding}" Foreground="Yellow" Background="Yellow" Click="OnSetColor"/>
                                                <MenuItem Header="Green" Tag="{Binding}" Foreground="Green" Background="Green" Click="OnSetColor"/>
                                                -->
                                            </ContextMenu>
                                        </TextBlock.ContextMenu>
                                    </TextBlock>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Grid.Row="1">
                                    <Label Content="Created: " FontSize="8" Foreground="DeepPink" VerticalContentAlignment="Center"/>
                                    <TextBlock Text="{Binding Path=CreationTime}" FontSize="8" Foreground="DeepPink" VerticalAlignment="Center"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Grid.Row="2">
                                    <Label Content="Last Updated: " FontSize="8" Foreground="RoyalBlue" VerticalContentAlignment="Center"/>
                                    <TextBlock Text="{Binding Path=UpdateTime}" FontSize="8" Foreground="RoyalBlue" VerticalAlignment="Center"/>
                                </StackPanel>
                            </Grid>
                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </ScrollViewer>
    </DockPanel>
</UserControl>
